#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e6 + 10;
int p[N];
int n, m;
int find(int x)
{
	if (x != p[x]) {
		p[x] = find(p[x]);
	}
	return p[x];
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		p[i] = i - 1;
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		if (a == 1) {
			int pa = find(a);
			int pb = 0;
			for (int i = 1; i <= n; i++) {
				if (find(i) == b) {
					pb = i;
					break;
				}
			}
			p[pb] = pa;
		}
		else {
			int pa = find(b);
			cout << pa << endl;
		}
	}
	return 0;
}